﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Berico="clr-namespace:Berico.Windows.Controls"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows">

    <!-- Style for Vertical GridSplitter Handle -->
    <Style x:Key="VerticalGridSplitterHandleStyle" TargetType="ToggleButton">
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="IsChecked" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid x:Name="Root">
                        
                         <!-- VSM -->
                         <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualTransition GeneratedDuration="0:0:00.5" To="MouseOver"/>
                                    <vsm:VisualTransition GeneratedDuration="0:0:00.5" To="Normal"/>
                                </vsm:VisualStateGroup.Transitions>
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackgroundBorder" Storyboard.TargetProperty="Opacity" Duration="00:00:00.3" To="1" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="CheckStates">
                                <vsm:VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="IconRotateTransform" Storyboard.TargetProperty="Angle" To="180" Duration="00:00:00" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unchecked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="IconRotateTransform" Storyboard.TargetProperty="Angle" To="0" Duration="00:00:00" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        
                        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                            <!-- Background -->
                            <Border x:Name="BackgroundBorder" BorderBrush="#FF000000" BorderThickness="0,1,0,1" Padding="0,5,0,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FF9B9B9B" Opacity="0" />
                            
                            <!-- Vertical Handle Icon -->
                            <Path Data="M0,0 L0,10 L5,5 Z" Stroke="Black" Fill="Black" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
                                <Path.RenderTransform>
                                    <RotateTransform x:Name="IconRotateTransform" Angle="0"/>
                                </Path.RenderTransform>
                            </Path>
                        </Grid>
                        
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Style for Horizontal GridSplitter Handle -->
    <Style x:Key="HorizontalGridSplitterHandleStyle" TargetType="ToggleButton">
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="IsChecked" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid x:Name="Root">

                        <!-- VSM -->
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualTransition GeneratedDuration="0:0:00.5" To="MouseOver"/>
                                    <vsm:VisualTransition GeneratedDuration="0:0:00.5" To="Normal"/>
                                </vsm:VisualStateGroup.Transitions>
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackgroundBorder" Storyboard.TargetProperty="Opacity" Duration="00:00:00.3" To="1" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="CheckStates">
                                <vsm:VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="IconRotateTransform" Storyboard.TargetProperty="Angle" To="180" Duration="00:00:00" />
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unchecked">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="IconRotateTransform" Storyboard.TargetProperty="Angle" To="0" Duration="00:00:00" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        
                        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                            <!-- Background -->
                            <Border x:Name="BackgroundBorder"  BorderBrush="#FF000000" BorderThickness="1,0,1,0" Padding="5,0,5,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FF9B9B9B" Opacity="0" />

                            <!-- Horizontal Handle Icon -->
                            <Path Data="M0,0 L10,0 L5,5 Z" Stroke="Black" Fill="Black" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
                                <Path.RenderTransform>
                                    <RotateTransform x:Name="IconRotateTransform" Angle="0"/>
                                </Path.RenderTransform>
                            </Path>
                        </Grid>
                        
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Style for GridSplitter Preview -->
    <Style x:Key="GridSplitterPreviewStyle" TargetType="Control">
        <Setter Property="Background" Value="#FF868686"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Control">
                    <Grid x:Name="Root" Opacity=".5">

                        <!-- Background -->
                        <Rectangle Fill="{TemplateBinding Background}" />

                        <!-- Horizontal Template -->
                        <Grid x:Name="HorizontalTemplate" Height="6">
                            <!-- Just show the faint gray grid splitter rectangle with no other details -->
                        </Grid>

                        <!-- Vertical Template -->
                        <Grid x:Name="VerticalTemplate" Visibility="Collapsed" Width="6">
                            <!-- Just show the faint gray grid splitter rectangle with no other details -->
                        </Grid>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Berico:GridSplitter control template -->
    <Style TargetType="Berico:GridSplitter">
        <Setter Property="Background" Value="#FFFFFFFF"/>
        <Setter Property="IsTabStop" Value="true"/>
        <Setter Property="PreviewStyle" Value="{StaticResource GridSplitterPreviewStyle}"/>
        <Setter Property="VerticalHandleStyle" Value="{StaticResource VerticalGridSplitterHandleStyle}" />
        <Setter Property="HorizontalHandleStyle" Value="{StaticResource HorizontalGridSplitterHandleStyle}" />
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Berico:GridSplitter">
                    <Grid x:Name="Root" IsHitTestVisible="{TemplateBinding IsEnabled}">

                        <!-- VSM -->
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal" />
                                <vsm:VisualState x:Name="MouseOver" />
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualTransition GeneratedDuration="0" />
                                </vsm:VisualStateGroup.Transitions>
                                <vsm:VisualState x:Name="Unfocused" />
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <!-- Background -->
                        <Rectangle x:Name="GridSplitterBackground" Fill="{TemplateBinding Background}" StrokeThickness="0" />

                        <!-- Horizontal Template -->
                        <Grid x:Name="HorizontalTemplate">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="50"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <!-- Horizontal GridSplitter Handle -->
                            <ToggleButton x:Name="HorizontalGridSplitterHandle" Grid.Column="1" IsHitTestVisible="True" Style="{TemplateBinding HorizontalHandleStyle}" RenderTransformOrigin="0.5,0.5">
                                <ToggleButton.RenderTransform>
                                    <ScaleTransform ScaleY="1" />
                                </ToggleButton.RenderTransform>
                            </ToggleButton>
                        </Grid>

                        <!-- Vertical Template -->
                        <Grid x:Name="VerticalTemplate" Visibility="Collapsed">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="50"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <!-- Vertical GridSplitter Handle -->
                            <ToggleButton x:Name="VerticalGridSplitterHandle" Grid.Row="1" IsHitTestVisible="True" Style="{TemplateBinding VerticalHandleStyle}" RenderTransformOrigin="0.5,0.5">
                                <ToggleButton.RenderTransform>
                                    <ScaleTransform ScaleX="1" />
                                </ToggleButton.RenderTransform>
                            </ToggleButton>
                        </Grid>

                        <!-- Focus Visual -->
                        <Rectangle x:Name="FocusVisual" Stroke="#FF6DBDD1" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Berico:Slider control template -->
    <Style TargetType="Berico:Slider">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="LowerRangeValue" Value="2" />
        <Setter Property="UpperRangeValue" Value="8" />
        <Setter Property="Maximum" Value="10" />
        <Setter Property="Minimum" Value="0" />
        <Setter Property="Value" Value="5" />
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AEB9" Offset="0"/>
                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                    <GradientStop Color="#FF718597" Offset="0.375"/>
                    <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Berico:Slider">
                    <Grid x:Name="LayoutRoot">
                        <Grid.Resources>
                            <ControlTemplate x:Key="RepeatButtonTemplate" TargetType="RepeatButton">
                                <Grid x:Name="LayoutRoot" Opacity="0" Background="Transparent"/>
                            </ControlTemplate>
                            <ControlTemplate x:Key="FillThumbTemplate" TargetType="Thumb">
                                <Grid x:Name="LayoutRoot">
                                    <vsm:VisualStateManager.VisualStateGroups>
                                        <vsm:VisualStateGroup x:Name="CommonStates">
                                            <vsm:VisualState x:Name="Normal"/>
                                            <vsm:VisualState x:Name="MouseOver"/>
                                            <vsm:VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOverlay" Storyboard.TargetProperty="Visibility" Duration="0">
                                                        <DiscreteObjectKeyFrame KeyTime="0">
                                                            <DiscreteObjectKeyFrame.Value>
                                                                <Visibility>Visible</Visibility>
                                                            </DiscreteObjectKeyFrame.Value>
                                                        </DiscreteObjectKeyFrame>
                                                    </ObjectAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </vsm:VisualState>
                                        </vsm:VisualStateGroup>
                                    </vsm:VisualStateManager.VisualStateGroups>

                                    <Rectangle Stroke="#FFA3AEB9" Fill="Blue" />
                                    <Rectangle x:Name="DisabledOverlay" Visibility="Collapsed" Opacity=".55" Stroke="#FFA3AEB9" Fill="White" />
                                </Grid>
                            </ControlTemplate>
                            <DataTemplate x:Key="DefaultTickMarkTemplate">
                                <Line Stroke="Black" StrokeThickness="1" />
                            </DataTemplate>
                        </Grid.Resources>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver"/>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HorizontalTrackRectangleDisabledOverlay" Storyboard.TargetProperty="Visibility" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ThumbDisabledOverlay" Storyboard.TargetProperty="Visibility" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>-->
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="VerticalTrackRectangleDisabledOverlay" Storyboard.TargetProperty="Visibility" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <!-- ToolTip -->
                        <Popup x:Name="ValueTipPopup" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <Grid x:Name="ValueTipPopupRoot" Height="Auto" Width="Auto">
                                <Border Padding="0,0,0,0" Margin="0,0,2,2" Height="Auto" Width="Auto" VerticalAlignment="Center" HorizontalAlignment="Center" Background="White" BorderBrush="#FF000000" BorderThickness="1,1,1,1">
                                    <TextBlock x:Name="ValueTipTextBlock" Margin="2" FontSize="10">
                                        <TextBlock.RenderTransform>
                                            <TransformGroup>
                                                <RotateTransform x:Name="ValueTipRotateTransform" Angle="0" />
                                            </TransformGroup>
                                        </TextBlock.RenderTransform>
                                    </TextBlock>
                                </Border>
                            </Grid>
                        </Popup>

                        <!-- Horizontal Template -->
                        <Grid x:Name="HorizontalTemplate">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <RepeatButton x:Name="HorizontalDecreaseHandle" Grid.Column="0" Margin="0,0,2,0" Height="15" Width="15" FontSize="9" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsTabStop="False" Content="-" />
                            <Canvas x:Name="HorizontalTickPanel" Margin="5,0,5,0" Grid.Column="1" Height="36" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                            <Grid x:Name="HorizontalSingleThumbTemplate" Grid.Column="1" Background="{TemplateBinding Background}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>

                                <!-- Track Layer -->
                                <Rectangle x:Name="HorizontalSingleThumbTrackRectangle" Stroke="#FFA3AEB9" StrokeThickness="{TemplateBinding BorderThickness}" Fill="#FFE6EFF7" Grid.Column="0" Grid.ColumnSpan="3" Height="3" RadiusX="1" RadiusY="1" Margin="5,0,5,0" />
                                <Rectangle x:Name="HorizontalTrackRectangleDisabledOverlay" Visibility="Collapsed"  Fill="White" Opacity=".55" Grid.Column="0" Grid.ColumnSpan="3" Height="3" RadiusX="1" RadiusY="1" Margin="5,0,5,0" />
                                
                                <!-- Repeat Buttons + Thumb -->
                                <RepeatButton x:Name="HorizontalSingleThumbLargeChangeDecreaseRepeatButton" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Column="0"/>
                                <Thumb Height="18" x:Name="HorizontalThumb" Width="11" Grid.Column="1" IsTabStop="True"/>
                                <!--<Rectangle x:Name="HorizontalSingleThumbDisabledOverlay" RadiusX="2" RadiusY="2"  Width="11" Grid.Column="1" Fill="White" Opacity=".55" Visibility="Collapsed"/>-->
                                <RepeatButton x:Name="HorizontalSingleThumbLargeChangeIncreaseRepeatButton" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Column="2"/>
                            </Grid>
                            <Grid x:Name="HorizontalRangeTemplate" Grid.Column="1" Background="{TemplateBinding Background}" Visibility="Collapsed">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>

                                <!-- Track Layer -->
                                <Rectangle x:Name="HorizontalRangeTrackRectangle" Stroke="#FFA3AEB9" StrokeThickness="{TemplateBinding BorderThickness}" Fill="#FFE6EFF7" Grid.Column="0" Grid.ColumnSpan="5" Height="3" RadiusX="1" RadiusY="1" Margin="5,0,5,0"/>

                                <!-- Repeat Buttons + Thumb (Lower) -->
                                <RepeatButton x:Name="HorizontalRangeLargeChangeDecreaseRepeatButton" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Column="0"/>
                                <Thumb x:Name="HorizontalLowerThumb" Width="11" Height="18" Grid.Column="1" IsTabStop="True" />
                                <!--<Rectangle x:Name="HorizontalLowerThumbDisabledOverlay" RadiusX="2" RadiusY="2" Width="11" Grid.Column="1" Fill="White" Opacity=".55" Visibility="Collapsed"/>-->

                                <!-- Track Filler:  Represents the actual range -->
                                <Thumb x:Name="HorizontalRangeThumb" Template="{StaticResource FillThumbTemplate}" Grid.Column="2" Height="3" />
                                <!--<Rectangle x:Name="HorizontalRangeThumbDisabledOverlay" Height="3" Grid.Column="2" Fill="White" Opacity=".55" Visibility="Collapsed"/>-->

                                <!-- Repeat Buttons + Thumb (Upper) -->
                                <Thumb x:Name="HorizontalUpperThumb" Width="11" Height="18" Grid.Column="3" IsTabStop="True" />
                                <!--<Rectangle x:Name="HorizontalUpperThumbDisabledOverlay" RadiusX="2" RadiusY="2" Width="11" Grid.Column="3" Fill="White" Opacity=".55" Visibility="Collapsed"/>-->

                                <RepeatButton x:Name="HorizontalRangeLargeChangeIncreaseRepeatButton" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Column="4"/>
                            </Grid>
                            <RepeatButton x:Name="HorizontalIncreaseHandle" Height="15" Width="15" IsTabStop="False" Grid.Column="2" Margin="2,0,0,0" FontSize="9" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="+" />
                        </Grid>
                        
                        <!-- Vertical Template -->
                        <Grid x:Name="VerticalTemplate" Visibility="Collapsed">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <RepeatButton x:Name="VerticalDecreaseHandle" Grid.Row="2" Margin="0,2,0,0" Height="15" Width="15" FontSize="9" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsTabStop="False" Content="-" />
                            <Grid x:Name="VerticalSingleThumbTemplate" Grid.Row="1" Background="{TemplateBinding Background}">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <!-- Track Layer -->
                                <Rectangle x:Name="VerticalSingleThumbTrackRectangle" Stroke="#FFA3AEB9" StrokeThickness="{TemplateBinding BorderThickness}" Fill="#FFE6EFF7" Grid.Row="0" Grid.RowSpan="3" Width="3" RadiusX="1" RadiusY="1" Margin="0,5,0,5" />
                                <Rectangle x:Name="VerticalTrackRectangleDisabledOverlay" Visibility="Collapsed"  Fill="White" Opacity=".55" Grid.Row="0" Grid.RowSpan="3" Width="3" RadiusX="1" RadiusY="1" Margin="0,5,0,5" />

                                <!-- Repeat Buttons + Thumb -->
                                <RepeatButton x:Name="VerticalSingleThumbLargeChangeDecreaseRepeatButton" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Row="2"/>
                                <Thumb Height="11" x:Name="VerticalThumb" Width="18" Grid.Row="1" IsTabStop="True"/>
                                <RepeatButton x:Name="VerticalSingleThumbLargeChangeIncreaseRepeatButton" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Row="0"/>
                            </Grid>
                            <Grid x:Name="VerticalRangeTemplate" Grid.Row="1" Background="{TemplateBinding Background}" Visibility="Collapsed">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <!-- Track Layer -->
                                <Rectangle x:Name="VerticalRangeTrackRectangle" Stroke="#FFA3AEB9" StrokeThickness="{TemplateBinding BorderThickness}" Fill="#FFE6EFF7" Grid.Row="0" Grid.RowSpan="5" Width="3" RadiusX="1" RadiusY="1" Margin="0,5,0,5" />

                                <!-- Repeat Buttons + Thumb (Lower) -->
                                <RepeatButton x:Name="VerticalRangeLargeChangeDecreaseRepeatButton" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Row="4"/>
                                <Thumb x:Name="VerticalLowerThumb" Width="18" Height="11" Grid.Row="3" IsTabStop="True" />
                                <!--<Rectangle x:Name="VerticalLowerThumbDisabledOverlay" RadiusX="2" RadiusY="2" Width="11" Grid.Row="31" Fill="White" Opacity=".55" Visibility="Collapsed"/>-->

                                <!-- Track Filler:  Represents the actual range -->
                                <Thumb x:Name="VerticalRangeThumb" Template="{StaticResource FillThumbTemplate}" Grid.Row="2" Width="3" />
                                <!--<Rectangle x:Name="VerticalRangeThumbDisabledOverlay" Width="3" Grid.Row="2" Fill="White" Opacity=".55" Visibility="Collapsed"/>-->

                                <!-- Repeat Buttons + Thumb (Upper) -->
                                <Thumb x:Name="VerticalUpperThumb" Width="18" Height="11" Grid.Row="1" IsTabStop="True" />
                                <!--<Rectangle x:Name="VerticalUpperThumbDisabledOverlay" RadiusX="2" RadiusY="2" Width="11" Grid.Row="1" Fill="White" Opacity=".55" Visibility="Collapsed"/>-->
                                <RepeatButton x:Name="VerticalRangeLargeChangeIncreaseRepeatButton" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate}" Grid.Row="0"/>

                            </Grid>
                            <RepeatButton x:Name="VerticalIncreaseHandle" Height="15" Width="15" IsTabStop="False" Grid.Row="0" Margin="0,2,0,0" FontSize="9" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="+" />
                        </Grid>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Berico:SplitButton control template -->
    <Style TargetType="Berico:SplitButton">
        <Setter Property="Height" Value="50" />
        <Setter Property="Width" Value="75" />
        <Setter Property="IsEnabled" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Berico:SplitButton">
                    <Grid x:Name="Root">
                        <Grid.Resources>
                            <Style x:Key="MacLeftGroupToolBarButtonStyle" TargetType="Button">
                                <Setter Property="IsEnabled" Value="true"/>
                                <Setter Property="IsTabStop" Value="true"/>
                                <Setter Property="Background" Value="#FFA9A9A9"/>
                                <Setter Property="Foreground" Value="#FF000000"/>
                                <Setter Property="MinWidth" Value="5"/>
                                <Setter Property="MinHeight" Value="5"/>
                                <Setter Property="Margin" Value="0"/>
                                <Setter Property="HorizontalAlignment" Value="Right" />
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                                <Setter Property="VerticalContentAlignment" Value="Center"/>
                                <Setter Property="Cursor" Value="Arrow"/>
                                <!--<Setter Property="TextAlignment" Value="Left"/>-->
                                <!--<Setter Property="TextWrapping" Value="NoWrap"/>-->
                                <!--<Setter Property="FontWeight" Value="Bold" />-->
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Grid Height="Auto" Width="Auto">
                                                <Grid.Resources>
                                                    <LinearGradientBrush x:Key="ButtonBorderGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                                                        <GradientStop Color="#FF4F4F4F"/>
                                                        <GradientStop Color="#FF464646" Offset="1"/>
                                                    </LinearGradientBrush>
                                                    <SolidColorBrush x:Key="DisabledBrush" Color="#A5FFFFFF"/>
                                                </Grid.Resources>
                                                <vsm:VisualStateManager.VisualStateGroups>
                                                    <vsm:VisualStateGroup x:Name="CommonStates">
                                                        <vsm:VisualStateGroup.Transitions>
                                                            <vsm:VisualTransition GeneratedDuration="0:0:0.2" To="Pressed"/>
                                                        </vsm:VisualStateGroup.Transitions>
                                                        <vsm:VisualState x:Name="Normal" >
                                                            <Storyboard/>
                                                        </vsm:VisualState>
                                                        <vsm:VisualState x:Name="Pressed">
                                                            <Storyboard>
                                                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#33FFFFFF"/>
                                                                </ColorAnimationUsingKeyFrames>
                                                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#66FFFFFF"/>
                                                                </ColorAnimationUsingKeyFrames>
                                                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
                                                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.05"/>
                                                                </DoubleAnimationUsingKeyFrames>
                                                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                                                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                                                </ColorAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </vsm:VisualState>
                                                        <vsm:VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="Opacity">
                                                                    <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                                                </DoubleAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </vsm:VisualState>
                                                    </vsm:VisualStateGroup>
                                                </vsm:VisualStateManager.VisualStateGroups>
                                                <Border x:Name="Background" BorderBrush="Transparent" BorderThickness="1" CornerRadius="5,0,0,5" Background="#FFA9A9A9" />
                                                <Border x:Name="BackgroundGradient" BorderBrush="{StaticResource ButtonBorderGradient}" BorderThickness="1" CornerRadius="5,0,0,5" >
                                                    <Border.Background>
                                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                            <GradientStop Color="#FCFFFFFF"/>
                                                            <GradientStop Color="#4CFFFFFF" Offset="1"/>
                                                        </LinearGradientBrush>
                                                    </Border.Background>
                                                </Border>
                                                <ContentPresenter x:Name="Content" Margin="4,5,4,4" 
                                                                  Content="{TemplateBinding Content}"
                                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                                <Border x:Name="DisabledVisual" Background="{StaticResource DisabledBrush}" BorderBrush="Transparent" BorderThickness="1" CornerRadius="5,0,0,5" Opacity="0" HorizontalAlignment="Stretch" />
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>

                            <Style x:Key="MacRightGroupToolBarButtonStyle" TargetType="Button">
                                <Setter Property="IsEnabled" Value="true"/>
                                <Setter Property="IsTabStop" Value="true"/>
                                <Setter Property="Background" Value="#FFA9A9A9"/>
                                <Setter Property="Foreground" Value="#FF000000"/>
                                <Setter Property="MinWidth" Value="5"/>
                                <Setter Property="MinHeight" Value="5"/>
                                <Setter Property="Margin" Value="0"/>
                                <Setter Property="HorizontalAlignment" Value="Left" />
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                                <Setter Property="VerticalContentAlignment" Value="Center"/>
                                <Setter Property="Cursor" Value="Arrow"/>
                                <!--<Setter Property="TextAlignment" Value="Left"/>
                                <Setter Property="TextWrapping" Value="NoWrap"/>-->
                                <!--<Setter Property="FontWeight" Value="Bold" />-->
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Grid>
                                                <Grid.Resources>
                                                    <LinearGradientBrush x:Key="ButtonBorderGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                                                        <GradientStop Color="#FF4F4F4F"/>
                                                        <GradientStop Color="#FF464646" Offset="1"/>
                                                    </LinearGradientBrush>
                                                    <SolidColorBrush x:Key="DisabledBrush" Color="#A5FFFFFF"/>
                                                </Grid.Resources>
                                                <vsm:VisualStateManager.VisualStateGroups>
                                                    <vsm:VisualStateGroup x:Name="CommonStates">
                                                        <vsm:VisualStateGroup.Transitions>
                                                            <vsm:VisualTransition GeneratedDuration="0:0:0.2" To="Pressed"/>
                                                        </vsm:VisualStateGroup.Transitions>
                                                        <vsm:VisualState x:Name="Normal" >
                                                            <Storyboard/>
                                                        </vsm:VisualState>
                                                                <vsm:VisualState x:Name="Pressed">
                                                            <Storyboard>
                                                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#33FFFFFF"/>
                                                                </ColorAnimationUsingKeyFrames>
                                                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#66FFFFFF"/>
                                                                </ColorAnimationUsingKeyFrames>
                                                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
                                                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.05"/>
                                                                </DoubleAnimationUsingKeyFrames>
                                                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                                                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                                                </ColorAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </vsm:VisualState>
                                                        <vsm:VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="Opacity">
                                                                    <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                                                </DoubleAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </vsm:VisualState>
                                                    </vsm:VisualStateGroup>
                                                </vsm:VisualStateManager.VisualStateGroups>
                                                <Border x:Name="Background" BorderBrush="Transparent" BorderThickness="1" CornerRadius="0,5,5,0" Background="#FFA9A9A9" />
                                                <Border x:Name="BackgroundGradient" BorderBrush="{StaticResource ButtonBorderGradient}" BorderThickness="1" CornerRadius="0,5,5,0" >
                                                    <Border.Background>
                                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                            <GradientStop Color="#FCFFFFFF"/>
                                                            <GradientStop Color="#4CFFFFFF" Offset="1"/>
                                                        </LinearGradientBrush>
                                                    </Border.Background>
                                                </Border>
                                                <ContentPresenter x:Name="Content" Margin="4,5,4,4" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
                                                <Border x:Name="DisabledVisual" Background="{StaticResource DisabledBrush}" BorderBrush="Transparent" BorderThickness="1" CornerRadius="0,5,5,0" Opacity="0" HorizontalAlignment="Stretch" />
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Grid.Resources>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Popup x:Name="DropDownPopup" HorizontalOffset="0" VerticalOffset="0">
                            <Grid Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Top" Opacity="1">
                                <Border x:Name="DropDownPopupBorder" Background="#F0F0F0" BorderBrush="#A0A0A0" BorderThickness="1,1,1,1" Margin="0,0,0,0" Height="Auto" Width="Auto">
                                    <ContentPresenter x:Name="DropDownPopupContent" Content="{TemplateBinding DropDownContent}" />
                                </Border>
                            </Grid>
                        </Popup>
                        <!--Style="{StaticResource MacLeftGroupToolBarButtonStyle}"  Style="{StaticResource MacRightGroupToolBarButtonStyle}"-->
                        <Button x:Name="ActionButton" Grid.Column="0" Content="{TemplateBinding Content}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" MinWidth="30" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                        <Button x:Name="PopupButton" Grid.Column="1" Width="15">
                            <Button.Content>
                                <Path StrokeThickness="1.000000" Stroke="#ff000000" StrokeMiterLimit="1.000000" Fill="#ff000000" Data="F1 M 0.944336,0.500000 L 18.996582,0.500000 L 10.462891,14.504395 L 0.944336,0.500000 Z" Stretch="Uniform"/>
                            </Button.Content>
                        </Button>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  Berico:ContextMenu control template [From Silverlight Toolkit]  -->
    <Style TargetType="Berico:ContextMenu">
        <Setter Property="Background" Value="#FFF5F5F5" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="#FF959595" />
        <Setter Property="Padding" Value="2" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Berico:ContextMenu">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="2">
                        <Border.Effect>
                            <DropShadowEffect Color="LightGray" ShadowDepth="3" />
                        </Border.Effect>
                        <Grid>
                            <Rectangle RadiusX="2" RadiusY="2" Fill="#FFF1F1F1" Width="28" Margin="2" HorizontalAlignment="Left" />
                            <Rectangle Fill="#FFE2E3E3" Width="1" Margin="30,2,0,2" HorizontalAlignment="Left" />
                            <Rectangle Fill="#FFFFFFFF" Width="1" Margin="31,2,0,2" HorizontalAlignment="Left" />
                            <ItemsPresenter Margin="{TemplateBinding Padding}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Berico:MenuItem control template [From Silverlight Toolkit] -->
    <Style TargetType="Berico:MenuItem">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Padding" Value="4,3,2,3" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Berico:MenuItem">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Presenter" Storyboard.TargetProperty="Opacity" To="0.5" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="CheckMark" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unchecked">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="CheckMark" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>                                
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Bg" Storyboard.TargetProperty="Opacity" To="1" />
                                        <ColorAnimation Duration="0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" To="#40FFFFFF" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle RadiusX="2" RadiusY="2" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" />
                        <Rectangle x:Name="Bg" RadiusX="2" RadiusY="2" Stroke="#8071CBF1" StrokeThickness="1" Opacity="0">
                            <Rectangle.Fill>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#34C5EBFF" Offset="0" />
                                        <GradientStop Color="#3481D8FF" Offset="1" />
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Rectangle x:Name="InnerBorder" RadiusX="2" RadiusY="2" Stroke="Transparent" Margin="1" />
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" MinWidth="24" />
                                <ColumnDefinition Width="4" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="37"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="17" />
                            </Grid.ColumnDefinitions>
                            <ContentPresenter Content="{TemplateBinding Icon}" Margin="1" VerticalAlignment="Center" />
                            <Border x:Name="CheckMark"
                                BorderThickness="1"
                                CornerRadius="3"
                                BorderBrush="#FFCDD3E6"
                                Background="#FFE6EFF4"
                                Width="22"
                                Height="22"
                                Margin="1"
                                Visibility="Collapsed">
                                <Path
                                    Data="M0,5.1L1.7,5.2 3.4,7.1 8,0.4 9.2,0 3.3,10.8z"
                                    Fill="#FF0C12A1"
                                    x:Name="Glyph"
                                    Width="9"
                                    Height="11"
                                    FlowDirection="LeftToRight"/>
                            </Border>
                            <ContentPresenter x:Name="Presenter" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" Margin="{TemplateBinding Padding}" Grid.Column="2" />
                            <Grid x:Name="SubMenuIndicator" Grid.Column="5" Visibility="Collapsed">
                                <Path Data="F1 M 511.047,352.682L 511.047,342.252L 517.145,347.467L 511.047,352.682 Z " Height="6" Width="5" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill" IsHitTestVisible="False" Fill="#FFE6E6E6" Margin="2,0,0,-2" StrokeThickness="2" Stroke="#FFE6E6E6" />
                                <Path Data="F1 M 511.047,352.682L 511.047,342.252L 517.145,347.467L 511.047,352.682 Z " Height="6" Width="5" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill" IsHitTestVisible="False" Fill="#FF414141" />
                            </Grid>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>

